<style>
    #formorder{padding: 10px 5px 10px 5px;}
    #formorder input,#formorder select{margin: 5px auto;}#formorder select{padding: 3px 0;}
    #formorder button{
        background: #5bc0de;color: #fff;border: 1px solid transparent;border-radius: 3px;
    }
    
    .page{border-top: 1px solid #E0E0E0;padding: 5px;}
    .page .page_count{padding-top: 5px;}
    .page .page_count label{display: inline-block;line-height: 30px;font-weight: normal;float: left;}
    .page .page_count .paginate_button{
        margin: 0 5px;
        float: left;
        background-color: #D5D5D5;
        padding: 5px 12px;
        color: #7d7d7d;
        border-radius: 3px;
    }
    .page .page_count .paginate_button:hover{
        background-color: #89affc;
        color: #fff;
    }
    .page .page_count .paginate_active{
        margin: 0 5px;
        float: left;
        padding: 5px 12px;
        color: #fff;
        background-color: #89affc;
        border-radius: 3px;
    }
    
    .cz_clik a{display: inline-block;background: #89affc;color: #fff;padding: 3px 10px;border-radius: 3px;height: 26px;margin: 5px;}
    .cz_clik a:hover{background: #89bffc;}
</style>
<link rel="stylesheet" href="/public/assets/sysadmin/mylzp/css/jquery-ui.css">
<script type="text/javascript" src="/public/assets/sysadmin/mylzp/js/jquery-ui.js"></script>
<section class="vbox">
    <section class="scrollable padder">
        <ul class="breadcrumb no-border no-radius b-b b-light pull-in">
            <li><a href="#"><i class="fa fa-home"></i>订单管理中心</a></li>
            <li><a href="#">订单管理</a></li>
            <li><a href="#">待处理订单</a></li>
        </ul>
        <div class="m-b-md">
            <h3 class="m-b-none"><span style="float:right;"><a href="/index.php/sysadmin/user/manageinfo"></a></span>待处理订单</h3>
        </div>
        <section class="panel panel-default">
            <header class="panel-heading">
                <i data-title="ajax to load the data." data-placement="bottom" data-toggle="tooltip" class="fa fa-info-sign text-muted" data-original-title="" title=""></i> 
                <b>待处理订单列表</b>
            </header>
            <div>
                <form action="<?=$this->url("order/processed")?>" method="get" id="formorder">
                    关键字 <input type="text" name="keyword" value="<?=!empty($getall)&&!empty($getall['keyword'])?$getall['keyword']:''?>" placeholder="订单号、姓名、电话" />
                    入住时间 <input type="text" name="statime" class="datepickerinput" readonly="" style="background: #fff;" value="<?=isset($getall['statime'])?$getall['statime']:''?>" placeholder="预定时间" class="input-date from" />
                    离开时间 <input type="text" name="endtime" class="datepickerinput" readonly="" style="background: #fff;" value="<?=isset($getall['endtime'])?$getall['endtime']:''?>" placeholder="离开时间" class="input-date to" />
                    支付类型 <select name="payType">
                        <option value="0">全部</option>
                        <option value="FG" <?=isset($getall['payType'])&&$getall['payType']=="FG"?'selected':''?>>现付</option>
                        <option value="PP" <?=isset($getall['payType'])&&$getall['payType']=="PP"?'selected':''?>>预付</option>
                        <option value="PKG" <?=isset($getall['payType'])&&$getall['payType']=="PKG"?'selected':''?>>打包</option>
                    </select>
                    <button>搜索</button>
                    <a href="<?=$this->url("order/processed")?>" style="font-size: 12px;color: red;margin-left: 10px;">显示全部</a>
                    
                </form>
            </div>
            <table data-ride="datatables" class="table table-striped m-b-none dataTable" id="DataTables_Table_0" >
            <thead>
                <tr role="row">
                    <th>订单号</th>
                    <th>客户姓名</th>
                    <th>客户电话</th>
                    <th>房型/床型</th>
                    <th>房间数</th>
                    <th>入/离时间</th>
                    <th>订单总价(元)</th>
                    <th>支付类型</th>
                    <th>订单来源</th>
                    <th>状态</th>
                    <th>操作</th>
                </tr>
            </thead>
            <tbody>
            <?
            if(!empty($re)){
                foreach($re as $k=>$v){?>
                <tr role="row">
                    <td><?=$v['orderId']?></td>
                    <td><?=$v['name']?></td>
                    <td><?=$v['mobile']?></td>
                    <td><?=$v['title']?> / <?=$v['bed']?></td>
                    <td><?=$v['countRoom']?></td>
                    <td><?=date('Y-m-d',$v['startDate'])?> / <?=date('Y-m-d',$v['endDate'])?></td>
                    <td><?=$v['price']?></td>
                    <td><?=$pmsconfigs['payType'][$v['payType']]?></td>
                    <td style="color: green;"><?=empty($v['typeName'])?'线下':$v['typeName']?></td>
                    <td style="color: red;"><?=$pmsconfigs['orderstatus'][$v['status']];?></td>
                    <td class="cz_clik">
                        <?
                        if($v['isbulu']==0){
                            if($v['status']==1){?>
                                <a href="javascript:;" class="show_shadefrist" onclick="submitorder('<?=$v['id']?>',4)">确认入住</a>
                            <?}
                            if(!empty($v['type']) && $v['type']=='301'){
                                if($v['status']==5){?>
                                    <a href="javascript:void(0);" style="background:red" data-id="<?=$v['id']?>">退款中</a>
                                <?}elseif($v['status']<2&&$v['payType']=='PP'&&$v['paid']!='0'){?>
                                    <a href="javascript:void(0);" class="tuikuan show_shadefrist" data-id="<?=$v['id']?>">退款</a>
                                <?}
                                if($v['status']==0){?>
                                    <a href="javascript:;" class="show_shadefrist" onclick="submitorder('<?=$v['id']?>',1,0)">确认有房</a>
                                    <a href="javascript:;" class="show_shadefrist" onclick="submitorder('<?=$v['id']?>',2,0)">确认无房</a>
                                <?}
                            }else{
                                if($v['status']==0){?>
                                    <a href="javascript:;" class="show_shadefrist" onclick="submitorder('<?=$v['id']?>',1,1)">确认有房</a>
                                    <a href="javascript:;" class="show_shadefrist" onclick="submitorder('<?=$v['id']?>',2,1)">确认无房</a>
                                <?}
                            }?>
                            <a href="<?=$this->url('order/detailsP?id='.$v['id'])?>">查看详情</a>
                        <?}else{?>
                            <a href="<?=$this->url('order/details?id='.$v['id'])?>">查看详情</a>
                        <?}
                        ?>
                    </td>
                </tr>
                <?}
            }else{?>
                <tr><td colspan="10">没有相关内容</td></tr>
            <?}
            ?>
            </tbody>
            </table>
            <div class="page">
                <?=$pageHtml?>
            </div>
        </section>
    </section>
</section>
<a href="#" class="hide nav-off-screen-block" data-toggle="class:nav-off-screen" data-target="#nav"></a>
<script>
$(function() {
	$(".datepickerinput").datepicker({
        minDate: '',
        showMonthAfterYear: true,
        changeMonth: true,
        numberOfMonths: 1,
        showOn: "both",
        showButtonPanel:true,
        duration: 100,
    });
    $('.ui-datepicker-trigger').remove();
});
//确认入住操作
function submitorder(orderid,status,type){
    $.ajax({
        type:'POST',
        url:'<?=$this->url("order/ordersEdit")?>',
        data:'id='+orderid+'&status='+status,
        dataType:'json',
        success:function(r){
            if(r.state==0){
                pub_alert_error(r.html,2000);
            }else if(r.state==1){
                pub_alert_success(r.html,2000);
                setTimeout(function(){window.location.reload();},2000);
            }
        },
        error:function(){
            pub_alert_error("ajax错误",2000);
        }
	});
}
$('.tuikuan').click(function(){
        var id = $(this).data('id'); 
        var obj = $(this);
        
        $.ajax({
    		type:'POST',
    		url:'<?=$this->url("order/ajaxSetOrder")?>',
    		data:'id='+id,
    		dataType:'json',
    		success:function(r){
                    if(r.state==0){
                        pub_alert_error(r.info,2000);
    		    }else if(r.state==1){
                        pub_alert_success(r.info,2000);
                        obj.removeClass('tuikuan');
                        obj.text('退款中') ;
                        obj.css('background','red');
    		    }
    		},
            error:function(){
                pub_alert_error("ajax错误",2000);
            }
    	});
    });
</script>